<#include "${ftl_skin}/common/header.ftl">


</head>
<body class="gray-bg">
<div class="wrapper wrapper-content animated fadeInRight">
    <div class="ibox float-e-margins">
        <div class="ibox-title">系统参数配置</div>
        <div class="ibox-content">




            <div class="row ibox float-e-margins">
                <div class="ibox-content">
                    <form id="formId"  class="form-horizontal" action="${path.servicePath }/admin/setconfig.do" method="post">

                        <input type="hidden" name="c_num" id="c_num" value="0"  />


                        <div class="form-group">
                            <label class="col-xs-2 control-label">登录页面LOGO</label>

                            <div class="col-xs-10">
                                <input id="LOGIN_LOGO" name="LOGIN_LOGO" key="LOGIN_LOGO" value="${config.LOGIN_LOGO! }" desc="登录页面LOGO" class="form-control normal config" nullmsg="请输入登录页面LOGO" datatype="*" class="required" errormsg="请输入登录页面LOGO" type="text" maxlength="50"/>
                            </div>
                        </div>

                        <div class="form-group">
                            <label class="col-xs-2 control-label">首页LOGO</label>

                            <div class="col-xs-10">
                                <input id="HOME_LOGO" name="HOME_LOGO" key="HOME_LOGO" value="${config.HOME_LOGO! }" desc="系统首页LOGO" class="form-control normal config" nullmsg="请输入首页LOGO" datatype="*" class="required" errormsg="请输入首页LOGO" type="text" maxlength="50"/>
                            </div>
                        </div>

                        <div class="hr-line-dashed"></div>
                        <div class="form-group">
                            <div class="col-xs-4 col-xs-offset-2">

                                <button type='button' class='btn btn-primary' onClick="javascript:saveConfig();return false;"> 确 定 </button>
                                <button type='button' class='btn btn-primary' onClick="javascript:refreshConfigCache();return false;"> 刷新缓存 </button> <span class="text-danger">(保存成功后需要刷新缓存才能生效)</span>

                            </div>
                        </div>
                    </form>
                </div>
            </div>




        </div><!-- end ibox-content -->
    </div><!-- end ibox -->
</div><!-- end wrap -->



<#include "${ftl_skin}/common/js.ftl">

<script type="text/javascript">
    $(function () {
        //初始化表单验证
        $("#formId").initValidform();
    });


    function addDynConfig(c_type){
        var num = parseInt($('#c_num').val());
        var s = '';
        s = '<div><input type="hidden" name="c_type_' + num + '" id="c_type_' + num + '" value="' + c_type + '" />';
        s += '名称 : <input type="text" name="c_name_' + num + '" id="c_name_' + num + '" value=""  style="width:20%;" />&nbsp;';
        s += 'Key : <input type="text" name="c_key_' + num + '" id="c_key_' + num + '" value=""  style="width:15%;" />&nbsp;';
        s += 'Value : <input type="text" name="c_value_' + num + '" id="c_value_' + num + '" value="" style="width:40%;" />';
        s += '</div>';
        $('#dynamic_div').append(s);

        num++;
        $('#c_num').val(num);
    }

    function addMenuConfig(c_type){
        var num = parseInt($('#c_num').val());
        var s = '';
        s = '<div><input type="hidden" name="c_type_' + num + '" id="c_type_' + num + '" value="' + c_type + '" />';
        s += '名称 : <input type="text" name="c_name_' + num + '" id="c_name_' + num + '" value=""  style="width:20%;" />&nbsp;';
        s += 'Key : <input type="text" name="c_key_' + num + '" id="c_key_' + num + '" value=""  style="width:15%;" />&nbsp;';
        s += 'Value : <input type="text" name="c_value_' + num + '" id="c_value_' + num + '" value="" style="width:40%;" />';
        s += '</div>';
        $('#menu_div').append(s);

        num++;
        $('#c_num').val(num);
    }

    // 保存配置
    function saveConfig(){
        var data = {};
        var num = 0;
        $('.config').each(function(){ // 先保存固定设置
            eval("data.key_" + num + " = '" + $(this).attr('key') + "';");
            eval("data.desc_" + num + " = '" + $(this).attr('desc') + "';");
            eval("data.val_" + num + " = '" + $(this).val() + "';");
            num++;
        });
        data.num = num;
        data.c_num = parseInt($('#c_num').val());
        for(var i = 0; i < data.c_num; i++){   // 再保存动态设置
            if($('#c_key_' + i).length > 0){  // 不加这个会出现 undefined 的项
                eval("data.c_key_" + i + " = '" + $('#c_key_' + i).val() + "';");
                eval("data.c_name_" + i + " = '" + $('#c_name_' + i).val() + "';");
                eval("data.c_value_" + i + " = '" + $('#c_value_' + i).val() + "';");
                eval("data.c_type_" + i + " = '" + $('#c_type_' + i).val() + "';");
            }
        }

        data.OPER_FLAG = "SAVE";     // 设置保存标记
        $.ajax({
            url: '${path.servicePath }/admin/setconfig.do',
            async: false,
            type: 'POST',
            data: data,
            success: function(msg){
                if(msg.ok){
                    alert("保存成功");
                }
            }
        });

    }

    // 删除一条配置
    function delConfig(key, divId){
        $.ajax({
            url: '${path.servicePath }/admin/delconfig.do',
            async: false,
            type: 'POST',
            data: {
                key:key
            },
            success: function(msg){
                if(msg.ok){
                    $('#' + divId).remove();
                }
            }
        });
    }

    // 刷新缓存
    function refreshConfigCache(){
        $.ajax({
            url: '${path.servicePath }/admin/refresh_config_cache.do',
            async: false,
            type: 'POST',
            data: {},
            success: function(msg){
                if(msg.state == 0){
                    alert("刷新成功");
                    winReload();
                }
            }
        });
    }

</script>

<#include "${ftl_skin}/common/footer.ftl">